﻿// FIV Fast Image viewer
// http://code.google.com/p/fiv/
// 
// Copyright 2013, Ken Rentz.
//
// This is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of
// the License, or (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this software; if not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
// 02110-1301 USA, or see the FSF site: http://www.fsf.org.
// 

using System.Linq;
using System.Windows.Forms;

namespace FIV
{
	public partial class ViewedImage : Form
	{
		private void HandleOpen()
		{
			OpenFileDialog openFile = new OpenFileDialog
			{
				CheckFileExists = true,
				CheckPathExists = true,
				Filter = "(*.jpg;*.jpeg*.gif;*.bmp)|*.jpg;*.jpeg;*.gif;*.bmp|All files (*.*)|*.*",
				FilterIndex = 0,
				Multiselect = true,
				ReadOnlyChecked = true,
				ShowHelp = true,
				SupportMultiDottedExtensions = true,
				ValidateNames = true
			};

			DialogResult dr = openFile.ShowDialog();
			if (dr == DialogResult.OK)
			{
				_Files.NewFiles(openFile.FileNames.ToList());
			}

			bool rc = _Image.Load(_Files.GetNextFile());
			if (rc)
			{
				ViewFile();
			}
		}

		private void HandleNext()
		{
			if (_Files.NumberOfFiles > 1)
			{
				bool rc = _Image.Load(_Files.GetNextFile());
				if (rc)
				{
					ViewFile();
				}
			}
		}

		private void HandleRandom()
		{
			if (_Files.NumberOfFiles > 1)
			{
				bool rc = _Image.Load(_Files.GetNextRandomFile());
				if (rc)
				{
					ViewFile();
				}
			}
		}

		private void HandlePrevious()
		{
			if (_Files.NumberOfFiles > 1)
			{
				bool rc = _Image.Load(_Files.GetPreviousFile());
				if (rc)
				{
					ViewFile();
				}
			}
		}

		private void HandleExit()
		{
			Close();
		}

	}
}
